package cn.kgc.springcloud.client;

import cn.kgc.springcloud.entity.Order;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author 课工场
 * @date 2023/10/10
 * @description
 */
@FeignClient("ORDERSERVICE")  //  注解属性表示需要调用服务的id
public interface OrderClient {

    @RequestMapping("/order/m1")
    String  method1();

    // http://localhost:8508/order/m2?id=10
    @RequestMapping("/order/m2")
    String  method2(@RequestParam("id") Integer id);


    // http://localhost:8508/order/m2/10   Restful
    @RequestMapping("/order/m3/{id}")
    String  method3(@PathVariable("id") Integer id);

    // http://localhost:8508/order/m4?id=10&name=mate60
    @RequestMapping("/order/m4")
    String  method4(@RequestParam("id") Integer id,@RequestParam("name")String name);

    // 通过在参数列表上添加@RequestBody注解  实现参数以json格式进行传递
    @RequestMapping("/order/m5")
    String  method5(@RequestBody Order order);


    //   ?ids=1&ids=2&ids=3
    @RequestMapping("/order/m6")
    String  method6(@RequestParam("ids") Integer[] ids);


    @RequestMapping("/order/m7/{id}")
    Order  method7(@PathVariable("id") Integer id);


    @RequestMapping("/order/m8")
    List<Order > method8();


}
